package com.maigao.persistent;

import com.maigao.entity.jpa.Coach;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CoachRepository extends JpaRepository<Coach, Long> {
    Coach findById(Integer id);

    Coach findByUserUid(String userUid);

    Coach findByCoachName(String coachName);

    Coach findByMobile(String mobile);

    Coach findByUserUidOrCoachName(Integer userUid, String coachName);

    List<Coach> findByStatus(Integer status);

    @Modifying
    @Query("update Coach set mobile = ?2 where id = ?1")
    Coach updateMobile(Integer coachId, String mobile);
}
